﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Wedo.Domain.Models;
using System.ComponentModel;

namespace Wedo.Recognition.Domain.Models
{
    [DisplayName("收款记录")]
    public class RecieveRecord:Entity
    {
        public RecieveRecord(DateTime  receiveDate, PostingType type, string assignment, string account, decimal amount, string SONO = "")
            : this()
        {
            Account = account;
            Amount = amount;
            Assignment = assignment;
            Posting = (int)type ;
            ReceiveDate = receiveDate;

            switch (type)
            {
                case PostingType.Recognition:
                    LineText = SONO;
                    Spe = "A";
                    TaxCode = "X0";
                    break;
                case PostingType.BankIn:

                    break;
            }
        }

        public RecieveRecord()
        {
            NewCompanyCode = string.Empty;
            Cctr = string.Empty;
            Pctr = string.Empty;
            Order = string.Empty;

            LineText = string.Empty;
            Spe = string.Empty;
            AssetCode = string.Empty;
            TaxCode = string.Empty;

            Plant = string.Empty;
            Quantity = string.Empty;
            Uom = string.Empty;
            Personnel = string.Empty;

            Functionnal = string.Empty;
            DistChannel = string.Empty;
            SalesOffice = string.Empty;
            Country = string.Empty;
            Cust = string.Empty;
        }

        /// <summary>
        /// 0 未生成,
        /// 1 生成成功
        /// 2 错误
        /// </summary>
        [DisplayName("状态")]
        public int Status { get; set; }

        /// <summary>
        /// 到账时间，只是日期
        /// </summary>
        [DisplayName("到账时间")]
        public DateTime ReceiveDate { get; set; }

        #region 必填字段

        /// <summary>
        /// 账单编号，必填
        /// </summary>
        [DisplayName("账单编号")]
        public string Assignment { get; set; }

        /// <summary>
        /// 交易类型，必填
        /// 19 认款
        /// 40 银行
        /// </summary>
        [DisplayName("交易类型")]
        public int Posting { get; set; }

        /// <summary>
        /// 账号，必填
        /// </summary>
        [DisplayName("客户编号")]
        public string Account { get; set; }

        /// <summary>
        /// 金额，必填
        /// </summary>
        [DisplayName("金额")]
        public decimal Amount { get; set; }
        #endregion

        #region 认款金额行必填字段

        /// <summary>
        /// 备注，认款金额行必填，格式：订单编号（金额）/订单编号（金额）
        /// </summary>
        public string LineText { get; set; }

        /// <summary>
        ///税码, 认款金额行必填“X0”
        /// </summary>
        public string TaxCode { get; set; }

        /// <summary>
        ///未知意义, 认款金额行必填“A”
        /// </summary>
        public string Spe { get; set; }
        #endregion

        #region 不填字段

        public string NewCompanyCode { get; set; }
        public string Cctr { get; set; }
        public string Pctr { get; set; }
        public string Order { get; set; }
        public string AssetCode { get; set; }

        public string Plant { get; set; }
        public string Quantity { get; set; }
        public string Uom { get; set; }
        public string Personnel { get; set; }

        public string Functionnal { get; set; }
        public string DistChannel { get; set; }
        public string SalesOffice { get; set; }
        public string Country { get; set; }
        public string Cust { get; set; }
        #endregion

    }

    /// <summary>
    /// Posting key
    /// </summary>
    public enum PostingType : int
    {
        /// <summary>
        /// 银行实收 40
        /// </summary>
        BankIn = 40,
        /// <summary>
        /// 认款总额 19
        /// </summary>
        Recognition = 19
    }
}
